﻿/*
 * Created by SharpDevelop.
 * User: IEscarro
 * Date: 8/29/2009
 * Time: 12:57 PM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using Buaya.Model;

namespace Buaya.Gui
{
	/// <summary>
	/// Description of DepartmentForm.
	/// </summary>
	public partial class DepartmentForm : BaseForm
	{
		public DepartmentForm() : this(new Department())
		{
			
		}
		
		public DepartmentForm(Department d)
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			Model = d;
		}
		
		protected override void OnModelChanged(EventArgs e)
		{
			base.OnModelChanged(e);
			Department d = Model as Department;
			textBoxName.Text = d.Name;
			textBoxAbbreviation.Text = d.Abbreviation;
			checkBoxInactive.Checked = d.Inactive;
		}
		
		void ButtonOkClick(object sender, EventArgs e)
		{
			Department d = Model as Department;
			d.Name = textBoxName.Text;
			d.Abbreviation = textBoxAbbreviation.Text;
			d.Inactive = checkBoxInactive.Checked;
			SessionFacade.SaveOrUpdateDepartment(d);
			Close();
		}
		
		void ButtonCancelClick(object sender, EventArgs e)
		{
			Close();
		}
	}
}
